home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Freeware 2002 November
/
SGI Freeware 2002 November - Disc 2.iso
/
dist
/
fw_groff.idb
/
usr
/
freeware
/
info
/
groff-4.z
/
groff-4
Wrap
Text File
|
2002-04-08
|
52KB
|
1,431 lines
This is groff, produced by makeinfo version 4.0 from groff.texinfo.
INFO-DIR-SECTION Miscellaneous
START-INFO-DIR-ENTRY
* Groff: (groff). The GNU troff document formatting system.
END-INFO-DIR-ENTRY
This Info file documents GNU troff version 1.16.
Published by the Free Software Foundation 59 Temple Place, Suite 330
Boston, MA 02111-1307 USA
Copyright (C) 1994-2000 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be stated in a
translation approved by the Foundation.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the section entitled "GNU General Public License" is included
exactly as in the original, and provided that the entire resulting
derived work is distributed under the terms of a permission notice
identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the section entitled "GNU General Public License"
may be included in a translation approved by the Free Software
Foundation instead of in the original English.
File: groff, Node: Page Layout, Next: Page Control, Prev: Line Layout, Up: gtroff Reference
Page Layout
===========
`gtroff' provides some very primitive operations for controlling
page layout.
- Request: .pl [length]
- Request: .pl +length
- Request: .pl -length
- Register: \n[.p]
Set the "page length" to LENGTH (or increment or decrement the
current value by LENGTH). This is the length of the physical
output page. The default scaling indicator is `v'.
The current setting can be found in the read-only number register
`.p'.
Note that this only specifies the size of the page, not the top and
bottom margins. Those are not set by `gtroff' directly. *Note
Traps::, for further information on how to do this.
Negative `pl' values are possible also, but not very useful: No
trap is sprung, and each line is output on a single page (thus
suppressing all vertical spacing).
If no argument or an invalid argument is given, `pl' sets the page
length to 11i.
`gtroff' provides several operations which help in setting up top
and bottom titles (or headers and footers).
- Request: .tl 'left'center'right'
Print a "title line". It consists of three parts: a left
justified portion, a centered portion, and a right justified
portion. The argument separator `'' can be replaced with any
character not occurring in the title line. The `%' character is
replaced with the current page number. This character can be
changed with the `pc' request (see below).
Without argument, `tl' is ignored.
Some notes:
* A title line is not restricted to the top or bottom of a page.
* `tl' prints the title line immediately, ignoring a partially
filled line (which stays untouched).
* It is not an error to omit closing delimiters. For example,
`.tl /foo' is equivalent to `.tl /foo///': It prints a title
line with the left justified word `foo'; the centered and
right justfied parts are empty.
* Any modifications to the current environment within `tl' (e.g.
changing the font or font size) are undone after processing
`tl'.
* `tl' accepts the same parameter delimiting characters as the
`\A' escape; see *Note Escapes::.
- Request: .lt [length]
- Request: .lt +length
- Request: .lt -length
- Register: \n[.lt]
The title line is printed using its own line length, which is
specified (or incremented or decremented) with the `lt' request.
Initially, the title line length is set to 6.5i. If a negative
line length is specified (which is not allowed), `gtroff' emits a
warning of type `range' and sets the title line length to zero.
The default scaling indicator is `m'. If `lt' is called without
an argument, the title length is reset to the previous value
before the last call to `lt'.
The current setting of this is available in the `.lt' read-only
number register; it is associated with the current environment
(*note Environments::).
- Request: .pn page
- Request: .pn +page
- Request: .pn -page
- Register: \n[.pn]
Change (increase or decrease) the page number of the _next_ page.
The only argument is the page number; the request is ignored
without a parameter.
The read-only number register `.pn' contains the number of the next
page: either the value set by a `pn' request, or the number of the
current page plus 1.
- Register: \n[%]
A read-write register holding the current page number.
- Request: .pc [char]
Change the page number character (used by the `tl' request) to a
different character. With no argument, this mechanism is disabled.
Note that this doesn't affect the number register `%'.
*Note Traps::.
File: groff, Node: Page Control, Next: Fonts, Prev: Page Layout, Up: gtroff Reference
Page Control
============
- Request: .bp [page]
- Request: .bp +page
- Request: .bp -page
Stop processing the current page and move to the next page. This
request causes a break. It can also take an argument to set
(increase, decrease) the page number of the next page. The only
difference between `bp' and `pn' is that `pn' does not cause a
break or actually eject a page.
.de newpage \" define macro
'bp \" begin page
'sp .5i \" vertical space
.tl 'left top'center top'right top' \" title
'sp .3i \" vertical space
.. \" end macro
`bp' has no effect if not called within the top-level diversion
(*note Diversions::).
- Request: .ne [space]
It is often necessary to force a certain amount of space before a
new page occurs. This is most useful to make sure that there is
not a single "orphan" line left at the bottom of a page. The `ne'
request ensures that there is a certain distance, specified by the
first argument, before the next page is triggered (see *Note
Traps::, for further information). The default unit for `ne' is
`v'; the default value of SPACE is 1v if no argument is given.
For example, to make sure that no fewer than 2 lines get orphaned,
do the following before each paragraph:
.ne 2
text text text
- Request: .sv [space]
`sv' is similar to the `ne' request; it reserves the specified
amount of vertical space. If the desired amount of space exists
before the next trap (bottom page boundary), the space is output
immediately (ignoring a partial filled line which stays
untouched). If there is not enough space, it is stored for later
output via the `os' request. The default value is 1v if no
argument is given; the default unit is `v'.
File: groff, Node: Fonts, Next: Sizes, Prev: Page Control, Up: gtroff Reference
Fonts
=====
`gtroff' can switch fonts at any point in the text.
The basic set of fonts is `R', `I', `B', and `BI'. These are Times
Roman, Italic, Bold, and Bold Italic. For non-tty devices, there is
also at least one symbol font which contains various special symbols
(Greek, mathematics).
* Menu:
* Changing Fonts::
* Font Families::
* Font Positions::
* Using Symbols::
* Special Fonts::
* Artificial Fonts::
* Ligatures and Kerning::
File: groff, Node: Changing Fonts, Next: Font Families, Prev: Fonts, Up: Fonts
Changing Fonts
--------------
- Request: .ft [font]
- Escape: \fF
- Escape: \f(FN
- Escape: \f[FONT]
The `ft' request and the `\f' escape change the current font to
FONT (one-character name F, two-character name FN).
If FONT is a style name (as set with the `sty' request or with the
`styles' command in the `DESC' file), use it within the current
font family (as set with the `fam' request or with the `family'
command in the `DESC' file).
With no argument or using `P' as an argument, `.ft' switches to
the previous font. Use `\fP' or `\f[P]' to do this with the
escape.
Fonts are generally specified as upper-case strings, which are
usually 1 to 4 characters representing an abbreviation or acronym
of the font name. This is no limitation, just a convention.
The example below produces two identical lines.
eggs, bacon,
.ft B
spam
.ft
and sausage.
eggs, bacon, \fBspam\fP and sausage.
*Note Font Positions::, for an alternative syntax.
- Request: .ftr f [g]
Translate font F to font G. Whenever a font named F is referred
to in a `\f' escape sequence, or in the `ft', `ul', `bd', `cs',
`tkf', `special', `fspecial', `fp', or `code' requests, font G is
used. If G is missing or equal to F the translation is undone.
File: groff, Node: Font Families, Next: Font Positions, Prev: Changing Fonts, Up: Fonts
Font Families
-------------
Due to the variety of fonts available, `gtroff' has added the
concept of "font families" and "font styles". The fonts are specified
as the concatenation of the font family and style. Specifying a font
without the family part causes `gtroff' to use that style of the
current family.
Currently, only POSTSCRIPT fonts are set up to this mechanism. By
default, `gtroff' uses the Times family with the four styles `R', `I',
`B', and `BI'.
This way, it is possible to use the basic four fonts and to select a
different font family on the command line (*note Groff Options::).
- Request: .fam [family]
- Register: \n[.fam]
Switch font family to FAMILY. If no argument is given, switch
back to the previous font family. The current font family is
available in the read-only number register `.fam' (this is a
string-valued register); it is associated with the current
environment.
spam,
.fam H \" helvetica family
spam, \" used font is family H + style R = HR
.ft B \" family H + style B = font HB
spam,
.fam T \" times family
spam, \" used font is family T + style B = TB
.ft AR \" font AR (not a style)
baked beans,
.ft R \" family T + style R = font TR
and spam.
- Request: .sty n style
Associate STYLE with font position N. A font position can be
associated either with a font or with a style. The current font
is the index of a font position and so is also either a font or a
style. When it is a style, the font that is actually used is the
font the name of which is the concatenation of the name of the
current family and the name of the current style. For example, if
the current font is 1 and font position 1 is associated with
style `R' and the current font family is `T', then font `TR' will
be used. If the current font is not a style, then the current
family is ignored. When the requests `cs', `bd', `tkf', `uf', or
`fspecial' are applied to a style, then they will instead be
applied to the member of the current family corresponding to that
style.
N must be a non-negative integer value.
The default family can be set with the `-f' option (*note Groff
Options::). The `styles' command in the `DESC' file controls
which font positions (if any) are initially associated with styles
rather than fonts. For example, the default setting for
POSTSCRIPT fonts
styles R I B BI
is equivalent to
.sty 1 R
.sty 2 I
.sty 3 B
.sty 4 BI
`.fam' always checks whether the current font position is valid;
this can give surprising results if the current font position is
associated with a style.
In the following example, we want to access the POSTSCRIPT font
`FooBar' from the font family `Foo':
.sty \n[.fp] Bar
.fam Foo
=> warning: can't find font `FooR'
The default font position at start-up is 1; for the POSTSCRIPT
device, this is associated with style `R', so `gtroff' tries to
open `FooR'.
A solution to this problem is to use a dummy font like the
following:
.fp 0 dummy TR \" set up dummy font at position 0
.sty \n[.fp] Bar \" register style `Bar'
.ft 0 \" switch to font at position 0
.fam Foo \" activate family `Foo'
.ft Bar \" switch to font `FooBar'
*Note Font Positions::.
File: groff, Node: Font Positions, Next: Using Symbols, Prev: Font Families, Up: Fonts
Font Positions
--------------
For the sake of old phototypesetters and compatibility with old
versions of `troff', `gtroff' has the concept of font "positions", on
which various fonts are mounted.
- Request: .fp pos font [external-name]
- Register: \n[.f]
- Register: \n[.fp]
Mount font FONT at position POS (which must be a non-negative
integer). This numeric position can then be referred to with font
changing commands. When `gtroff' starts it is using font
position 1 (which must exist; position 0 is unused usually at
start-up).
The current font in use, as a font position, is available in the
read-only number register `.f'. This can be useful to remember the
current font for later recall. It is associated with the current
environment (*note Environments::).
.nr save-font \n[.f]
.ft B
... text text text ...
.ft \n[save-font]
The number of the next free font position is available in the
read-only number register `.fp'. This is useful when mounting a
new font, like so:
.fp \n[.fp] NEATOFONT
Fonts not listed in the `DESC' file are automatically mounted on
the next available font position when they are referenced. If a
font is to be mounted explicitly with the `fp' request on an unused
font position, it should be mounted on the first unused font
position, which can be found in the `.fp' register. Although
`gtroff' does not enforce this strictly, it is not allowed to
mount a font at a position whose number is much greater (approx.
1000 positions) than that of any currently used position.
The `fp' request has an optional third argument. This argument
gives the external name of the font, which is used for finding the
font description file. The second argument gives the internal
name of the font which is used to refer to the font in `gtroff'
after it has been mounted. If there is no third argument then the
internal name is used as the external name. This feature makes it
possible to use fonts with long names in compatibility mode.
Both the `ft' request and the `\f' escape have alternative syntax
forms to access font positions.
- Request: .ft nnn
- Escape: \fN
- Escape: \f(NN
- Escape: \f[NNN]
Change the current font position to NNN (one-digit position N,
two-digit position NN), which must be a non-negative integer.
If NNN is associated with a style (as set with the `sty' request
or with the `styles' command in the `DESC' file), use it within
the current font family (as set with the `fam' request or with the
`family' command in the `DESC' file).
this is font 1
.ft 2
this is font 2
.ft \" switch back to font 1
.ft 3
this is font 3
.ft
this is font 1 again
*Note Changing Fonts::, for the standard syntax form.
File: groff, Node: Using Symbols, Next: Special Fonts, Prev: Font Positions, Up: Fonts
Using Symbols
-------------
A "glyph" is a graphical representation of a "character". While a
character is an abstract entity containing semantic information, a
glyph is something which can be actually seen on screen or paper. It
is possible that a character has multiple glyph representation forms
(for example, the character `A' can be either written in a roman or an
italic font, yielding two different glyphs); sometimes more than one
character maps to a single glyph (this is a "ligature" - the most
common is `fi').
Please note that currently the distinction between glyphs and
characters in this reference is not clearly carried out. This will be
improved eventually in the next revision.
A "symbol" is simply a named glyph. Within `gtroff', all glyph
names of a particular font are defined in its font file. If the user
requests a glyph not available in this font, `gtroff' looks up an
ordered list of "special fonts". By default, the POSTSCRIPT output
device supports the two special fonts `SS' (slanted symbols) and `S'
(symbols) (the former is looked up before the latter). Other output
devices use different names for special fonts. Fonts mounted with the
`fonts' keyword in the `DESC' file are globally available. To install
additional special fonts locally (i.e. for a particular font), use the
`fspecial' request.
*Note Font Files::, and *Note Special Fonts::, for more details.
- Escape: \(NM
- Escape: \[NAME]
Insert a symbol NAME (two-character name NM). There is no special
syntax for one-character names - the natural form `\N' would
collide with escapes.
If NAME is undefined, a warning of type `char' is generated, and
the escape is ignored. *Note Debugging::, for information about
warnings.
The list of available symbols is device dependent; see *Note Glyph
Name Index:: for some of them discussed in this reference.
- Escape: \C'XXX'
Typeset the character named XXX. Normally it is more convenient
to use `\[XXX]', but `\C' has the advantage that it is compatible
with newer versions of `ditroff' and is available in compatibility
mode.
- Escape: \N'N'
Typeset the character with code N in the current font (this is
*not* the input character code). N can be any integer. Most
devices only have characters with codes between 0 and 255; the
Unicode output device uses codes in the range 0-65535. If the
current font does not contain a character with that code, special
fonts are _not_ searched. The `\N' escape sequence can be
conveniently used in conjunction with the `char' request:
.char \[phone] \f[ZD]\N'37'
The code of each character is given in the fourth column in the
font description file after the `charset' command. It is possible
to include unnamed characters in the font description file by
using a name of `---'; the `\N' escape sequence is the only way to
use these.
- Request: .cflags n c1 c2 ...
Each character has certain properties associated with it. These
properties can be modified with the `cflags' request. The first
argument is the the sum of the desired flags and the remaining
arguments are the characters to have those properties. It is
possible to omit the spaces between the characters.
`1'
the character ends sentences (initially characters `.?!' have
this property)
`2'
lines can be broken before the character (initially no
characters have this property)
`4'
lines can be broken after the character (initially the
characters `-\(hy\(em' have this property)
`8'
the character overlaps horizontally (initially the characters
`\(ul\(rn\(ru' have this property)
`16'
the character overlaps vertically (initially character `\(br'
has this property)
`32'
an end of sentence character followed by any number of
characters with this property is treated as the end of a
sentence if followed by a newline or two spaces; in other
words the character is "transparent" for the purposes of end
of sentence recognition - this is the same as having a zero
space factor in TeX (initially characters `"')]*\(dg\(rq'
have this property).
- Request: .char c [string]
Define a new character C to be STRING (which can be empty). Every
time character C needs to be printed, STRING is processed in a
temporary environment and the result is wrapped up into a single
object. Compatibility mode is turned off and the escape character
is set to `\' while STRING is being processed. Any emboldening,
constant spacing or track kerning is applied to this object rather
than to individual characters in STRING. A character defined by
this request can be used just like a normal character provided by
the output device. In particular, other characters can be
translated to it with the `tr' request; it can be made the leader
character by the `lc' request; repeated patterns can be drawn with
the character using the `\l' and `\L' escape sequences; words
containing the character can be hyphenated correctly, if the
`hcode' request is used to give the character a hyphenation code.
There is a special anti-recursion feature: Use of character within
the character's definition is handled like normal characters not
defined with `char'.
- Request: .rchar c1 c2 ...
Remove the definitions of characters C1, C2, .... This undoes the
effect of a `char' request.
It is possible to omit the whitespace between arguments.
*Note Special Characters::.
File: groff, Node: Special Fonts, Next: Artificial Fonts, Prev: Using Symbols, Up: Fonts
Special Fonts
-------------
To be written.
File: groff, Node: Artificial Fonts, Next: Ligatures and Kerning, Prev: Special Fonts, Up: Fonts
Artificial Fonts
----------------
There are a number of requests for artificially creating fonts.
These are largely vestiges of the days when output devices did not have
a wide variety of fonts, and when `nroff' and `troff' were separate
programs. These are no longer necessary in GNU `troff'. Nevertheless,
they are supported.
- Request: .ul [lines]
The `ul' request normally underlines subsequent lines if a tty
output device is used. Otherwise, the lines are printed in italics
(only the term `underlined' is used in the following). The single
argument is the number of input lines to be underlined; with no
argument, the next line is underlined. If LINES is zero or
negative, stop the effects of `ul' (if it was active). Requests
and empty lines do not count for computing the number of underlined
input lines, even if they produce some output like `tl'. Lines
inserted by macros (e.g. invoked by a trap) do count.
At the beginning of `ul', the current font is stored and the
underline font is activated. Within the span of a `ul' request,
it is possible to change fonts, but after the last line affected by
`ul' the saved font is restored.
This command is associated with the current environment. The
underline font can be changed with the `uf' request.
*Note Troff and Nroff Mode::, for a discussion how underlining is
implemented in for tty output devices, and which problems can
arise.
The `ul' request does not underline spaces.
- Request: .cu [lines]
The `cu' request is similar to `ul' but underlines spaces as well
(if a tty output device is used).
- Request: .uf font
Set the underline font (globally) used by `ul' and `cu'. By
default, this is the font at position 2. FONT can be either a
non-negative font position or the name of a font.
- Request: .bd font [offset]
- Request: .bd font1 font2 [offset]
- Register: \n[.b]
Artificially create a bold font by printing each character twice,
slightly offset.
Two syntax forms are available.
* Imitate a bold font unconditionally. The first argument
specifies the font to embolden, and the second is the number
of basic units, minus one, by which the two characters is
offset. If the second argument is missing, emboldening is
turned off.
FONT can be either a non-negative font position or the name
of a font.
OFFSET is available in the `.b' read-only register if a
special font is active; in the `bd' request, its default unit
is `u'.
* Imitate a bold form conditionally. Embolden FONT1 by OFFSET
only if font FONT2 is the current font. This command can be
issued repeatedly to set up different emboldening values for
different current fonts. If the second argument is missing,
emboldening is turned off for this particular current font.
This affects special fonts only (either set up with the
`special' command in font files or with the `fspecial'
request).
- Request: .cs font [width [em-size]]
Switch to and from constant character space mode. If activated,
the width of every character is WIDTH/36 ems. The em size is
given absolutely by EM-SIZE; if this argument is missing, the em
value is taken from the current font size (as set with the `ps'
request) when the font is effectively in use. Without second and
third argument, constant character space mode is deactivated.
Default unit for EM-SIZE is `z'; WIDTH is an integer.
File: groff, Node: Ligatures and Kerning, Prev: Artificial Fonts, Up: Fonts
Ligatures and Kerning
---------------------
Ligatures are groups of characters that are run together. For
example, the letters `f' and `i' can form a ligature `fi' as in the
word `file'. This produces a cleaner look (albeit subtle) to the
printed output. Usually, ligatures are not available in fonts for tty
output devices.
Most POSTSCRIPT fonts support the fi and fl ligatures. The C/A/T
typesetter that was the target of AT&T `troff' also supported `ff',
`ffi', and `ffl' ligatures. Advanced typesetters or `expert' fonts may
include ligatures for `ft' and `ct', although GNU `troff' does not
support these (yet).
- Request: .lg [flag]
- Register: \n[.lg]
The ligature mechanism can be switched on or off with the `lg'
request; if the parameter is non-zero or missing, ligatures are
enabled, otherwise disabled. Default is on. The current ligature
mode can be found in the read-only number register `.lg' (set to 1
or 2 if ligatures are enabled, 0 otherwise).
Setting the ligature mode to 2 enables the two-character ligatures
(fi, fl, and ff) and disables the three-character ligatures (ffi
and ffl).
"Pairwise kerning" is another subtle typesetting mechanism that
modifies the distance between a character pair to improve readability.
In most cases (but not always) the distance is decreased.
Typewriter-like fonts and fonts for terminals where all characters have
the same width don't use kerning.
- Request: .kern [flag]
- Register: \n[.kern]
Kerning can be activated with the `kern' request. If the
parameter is non-zero or missing, enable pairwise kerning,
otherwise disable it. The read-only number register `.kern' is
set to 1 if pairwise kerning is enabled, 0 otherwise.
If the font description file contains pairwise kerning information,
characters from that font are kerned. Kerning between two
characters can be inhibited by placing `\&' between them: `V\&A'.
*Note Font File Format::.
"Track kerning" expands or reduces the space between characters.
This can be handy, for example, if you need to squeeze a long word onto
a single line or spread some text to fill a narrow column. It must be
used with great care since it is usually considered bad typography if
the reader notices the effect.
- Request: .tkf f s1 n1 s2 n2
Enable track kerning for font F. If the current font is F the
width of every character is increased by an amount between N1 and
N2 (N1, N2 can be negative); if the current point size is less
than or equal to S1 the width is increased by N1; if it is greater
than or equal to S2 the width is increased by N2; if the point
size is greater than or equal to S1 and less than or equal to S2
the increase in width is a linear function of the point size.
The default unit is `z' for S1 and S2, `p' for N1 and N2.
Sometimes, when typesetting letters of different fonts, more or less
space at such boundaries are needed. There are two escapes to help
with this.
- Escape: \/
Increase the width of the preceding character so that the spacing
between that character and the following character is correct if
the following character is a roman character. For example, if an
italic `f' is immediately followed by a roman right parenthesis,
then in many fonts the top right portion of the `f' overlaps the
top left of the right parenthesis. Use this escape sequence
whenever an italic character is immediately followed by a roman
character without any intervening space. This small amount of
space is also called "italic correction".
- Escape: \,
Modify the spacing of the following character so that the spacing
between that character and the preceding character is correct if
the preceding character is a roman character. Use this escape
sequence whenever a roman character is immediately followed by an
italic character without any intervening space. In analogy to
above, this space could be called "left italic correction", but
this term isn't used widely.
- Escape: \&
Insert a zero-width character, which is invisible. Its intended
use is to stop interaction of a character with its surrounding.
* It prevents the insertion of extra space after an end of
sentence character.
Test.
Test.
=> Test. Test.
Test.\&
Test.
=> Test. Test.
* It prevents interpretation of a control character at the
beginning of an input line.
.Test
=> warning: `Test' not defined
\&.Test
=> .Test
* It prevents kerning between two characters.
* It is needed to map an arbitrary character to nothing in the
`tr' request (*note Character Translations::).
File: groff, Node: Sizes, Next: Strings, Prev: Fonts, Up: gtroff Reference
Sizes
=====
`gtroff' uses two dimensions with each line of text, type size and
vertical spacing. The "type size" is approximately the height of the
tallest character.(1) (*note Sizes-Footnote-1::) "Vertical spacing" is
the amount of space `gtroff' allows for a line of text; normally, this
is about 20% larger than the current type size. Ratios smaller than
this can result in hard-to-read text; larger than this, it spreads the
text out more vertically (useful for term papers). By default,
`gtroff' uses 10 point type on 12 point spacing.
The difference between type size and vertical spacing is known, by
typesetters, as "leading".
* Menu:
* Changing Type Sizes::
* Fractional Type Sizes::
File: groff, Node: Sizes-Footnotes, Up: Sizes
(1) This is usually the parenthesis. Note that in most cases the
real dimensions of the glyphs in a font are _not_ related to its type
size! For example, the standard POSTSCRIPT font families `Times
Roman', `Helvetica', and `Courier' can't be used together at 10pt; to
get acceptable output, the size of `Helvetica' has to be reduced by one
point, and the size of `Courier' must be increased by one point.
File: groff, Node: Changing Type Sizes, Next: Fractional Type Sizes, Prev: Sizes, Up: Sizes
Changing Type Sizes
-------------------
- Request: .ps [size]
- Request: .ps +size
- Request: .ps -size
- Escape: \sSIZE
- Register: \n[.s]
Use the `ps' request or the `\s' escape to change (increase,
decrease) the type size (in points). Specify SIZE as either an
absolute point size, or as a relative change from the current size.
The size 0, or no argument, goes back to the previous size.
Default unit of `size' is `z'. If `size' is zero or negative, it
is set to 1u.
The read-only number register `.s' returns the point size in
points as a decimal fraction. This is a string. To get the point
size in scaled points, use the `.ps' register instead.
`.s' is associated with the current environment (*note
Environments::).
snap, snap,
.ps +2
grin, grin,
.ps +2
wink, wink, \s+2nudge, nudge,\s+8 say no more!
.ps 10
The `\s' escape may be called in a variety of ways. Much like
other escapes there must be a way to determine where the argument
ends and the text begins. Any of the following forms are valid:
`\sN'
Set the point size to N points. N must be either 0 or in the
range 4 to 39.
`\s+N'
`\s-N'
Increase or decrease the point size by N points. N must be
exactly one digit.
`\s(NN'
Set the point size to NN points. NN must be exactly two
digits.
`\s+(NN'
`\s-(NN'
`\s(+NN'
`\s(-NN'
Increase or decrease the point size by NN points. NN must be
exactly two digits.
*Note Fractional Type Sizes::, for yet another syntactical form of
using the `\s' escape.
Some devices may only have certain permissible sizes, in which case
`gtroff' rounds to the nearest permissible size.
- Request: .vs [space]
- Request: .vs +space
- Request: .vs -space
- Register: \n[.v]
Change (increase, decrease) the vertical spacing by SPACE. The
default unit is `p'.
If `vs' is called without an argument, the vertical spacing is
reset to the previous value before the last call to `vs'.
`gtroff' creates a warning of type `range' if SPACE is zero or
negative; the vertical spacing is then set to the vertical
resolution (as given in the `.V' register).
The read-only number register `.v' contains the current vertical
spacing; it is associated with the current environment (*note
Environments::).
File: groff, Node: Fractional Type Sizes, Prev: Changing Type Sizes, Up: Sizes
Fractional Type Sizes
---------------------
A "scaled point" is equal to 1/SIZESCALE points, where SIZESCALE is
specified in the `DESC' file (1 by default). There is a new scale
indicator `z' which has the effect of multiplying by SIZESCALE.
Requests and escape sequences in `gtroff' interpret arguments that
represent a point size as being in units of scaled points, but they
evaluate each such argument using a default scale indicator of `z'.
Arguments treated in this way are the argument to the `ps' request, the
third argument to the `cs' request, the second and fourth arguments to
the `tkf' request, the argument to the `\H' escape sequence, and those
variants of the `\s' escape sequence that take a numeric expression as
their argument (see below).
For example, suppose SIZESCALE is 1000; then a scaled point is
equivalent to a millipoint; the request `.ps 10.25' is equivalent to
`.ps 10.25z' and thus sets the point size to 10250 scaled points, which
is equal to 10.25 points.
`gtroff' disallows the use of the `z' scale indicator in instances
where it would make no sense, such as a numeric expression whose
default scale indicator was neither `u' nor `z'. Similarly it would
make no sense to use a scaling indicator other than `z' or `u' in a
numeric expression whose default scale indicator was `z', and so
`gtroff' disallows this as well.
There is also new scale indicator `s' which multiplies by the number
of units in a scaled point. So, for example, `\n[.ps]s' is equal to
`1m'. Be sure not to confuse the `s' and `z' scale indicators.
- Register: \n[.ps]
A read-only number register returning the point size in scaled
points.
`.ps' is associated with the current environment (*note
Environments::).
- Register: \n[.psr]
- Register: \n[.sr]
The last-requested point size in scaled points is contained in the
`.psr' read-only number register. The last requested point size
in points as a decimal fraction can be found in `.sr'. This is a
string-valued read-only number register.
Note that the requested point sizes are device-independent, whereas
the values returned by the `.ps' and `.s' registers are not. For
example, if a point size of 11pt is requested for a DVI device,
10.95pt are actually used (as specified in the `DESC' file).
Both registers are associated with the current environment (*note
Environments::).
The `\s' escape has the following syntax for working with fractional
type sizes:
`\s[N]'
`\s'N''
Set the point size to N scaled points; N is a numeric expression
with a default scale indicator of `z'.
`\s[+N]'
`\s[-N]'
`\s+[N]'
`\s-[N]'
`\s'+N''
`\s'-N''
`\s+'N''
`\s-'N''
Increase or or decrease the point size by N scaled points; N is a
numeric expression with a default scale indicator of `z'.
*Note Font Files::.
File: groff, Node: Strings, Next: Conditionals and Loops, Prev: Sizes, Up: gtroff Reference
Strings
=======
`gtroff' has string variables, which are entirely for user
convenience (i.e. there are no built-in strings exept `.T', but even
this is a read-write string variable).
- Request: .ds name [string]
- Escape: \*N
- Escape: \*(NM
- Escape: \*[NAME]
Define and access a string variable NAME (one-character name N,
two-character name NM). If NAME already exists, `ds' overwrites
the previous definition.
Example:
.ds UX \s-1UNIX\s0\u\s-3tm\s0\d
.
The \*(UX Operating System
The `\*' escape "interpolates" (expands in-place) a
previously-defined string variable. To be more precise, the stored
string is pushed onto the input stack which is then parsed by
`gtroff'. Similar to number registers, it is possible to nest
strings, i.e. a string variables can be called within string
variables.
If the string named by the `\*' does not exist, it is defined as
empty, and a warning of type `mac' is emitted (see *Note
Debugging::, for more details).
*Caution:* Unlike other requests, the second argument to the `ds'
request takes up the entire line including trailing spaces. This
means that comments on a line with such a request can introduce
unwanted space into a string.
.ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
Instead the comment should be put on another line or have the
comment escape adjacent with the end of the string.
.ds UX \s-1UNIX\s0\u\s-3tm\s0\d\" UNIX trademark
To produce leading space the string can be started with a double
quote. No trailing quote is needed; in fact, any trailing quote is
included in your string.
.ds sign " Yours in a white wine sauce,
Strings are not limited to a single line of text. A string can
span several lines by escaping the newlines with a backslash. The
resulting string is stored _without_ the newlines.
.ds foo lots and lots \
of text are on these \
next several lines
It is not possible to have real newlines in a string.
Strings, macros, and diversions (and boxes) share the same name
space. Internally, even the same mechanism is used to store them.
This has some interesting consequences. For example, it is
possible to call a macro with string syntax and vice versa.
.de xxx
a funny test.
..
This is \*[xxx]
=> This is a funny test.
.ds yyy a funny test
This is
.yyy
=> This is a funny test.
Diversions and boxes can be also called with string syntax. It is
not possible to pass arguments to a macro if called with `\*'.
Another consequence is that you can copy one-line diversions or
boxes to a string.
.di xxx
a \fItest\fR
.br
.di
.ds yyy This is \*[xxx]\c
\*[yyy].
=> This is a test.
As the previous example shows, it is possible to store formatted
output in strings. The `\c' escape prevents the insertion of an
additional blank line in the output.
Copying diversions longer than a single output line produces
unexpected results.
.di xxx
a funny
.br
test
.br
.di
.ds yyy This is \*[xxx]\c
\*[yyy].
=> test This is a funny.
Usually, it is not predictable whether a diversion contains one or
more output lines, so this mechanism should be avoided. With UNIX
`troff', this was the only solution to strip off a final newline
from a diversion. Another disadvantage is that the spaces in the
copied string are already formatted, making them unstretchable.
This can cause ugly results.
A clean solution to this problem is available in GNU `troff',
using the requests `chop' to remove the final newline of a
diversion, and `unformat' to make the horizontal spaces
stretchable again.
.box xxx
a funny
.br
test
.br
.box
.chop xxx
.unformat xxx
This is \*[xxx].
=> This is a funny test.
*Note Gtroff Internals::, for more information.
- Request: .as name [string]
The `as' request is similar to `ds' but appends STRING to the
string stored as NAME instead of redefining it. If NAME doesn't
exist yet, it is created.
.as sign " with shallots, onions and garlic,
Rudimentary string manipulation routines are given with the next two
requests.
- Request: .substring str n1 [n2]
Replace the string in register STR with the substring defined by
the indices N1 and N2. The first character in the string has
index one. If N2 is omitted, it is taken to be equal to the
string's length. If the index value N1 or N2 is negative or zero,
it is counted from the end of the string, going backwards: The
last character has index 0, the character before the last
character has index -1, etc.
.ds xxx abcdefgh
.substring xxx 2 -3
\*[xxx]
=> bcde
- Request: .length reg str
Compute the length of STR and returns it in the number
register REG. If REG doesn't exist, it is created.
.ds xxx abcdefgh
.length yyy xxx
\n[yyy]
=> 8
- Request: .rn xx yy
Rename the request, macro, or string XX to YY.
- Request: .rm xx
Remove the request, macro, or string XX. `gtroff' treats
subsequent invocations as if the object had never been defined.
- Request: .als new old
Create an alias named NEW for the request, string, macro, or
diversion object named OLD. The new name and the old name are
exactly equivalent (it is similar to a hard rather than a soft
link). If OLD is undefined, `gtroff' generates a warning of type
`mac' and ignores the request.
- Request: .chop xx
Remove (chop) the last character from the macro, string, or
diversion named XX. This is useful for removing the newline from
the end of diversions that are to be interpolated as strings.
This command can be used repeatedly; see *Note Gtroff Internals::,
for details on nodes inserted by `gtroff' automatically.
*Note Identifiers::, and *Note Comments::.
File: groff, Node: Conditionals and Loops, Next: Writing Macros, Prev: Strings, Up: gtroff Reference
Conditionals and Loops
======================
* Menu:
* Operators in Conditionals::
* if-else::
* while::
File: groff, Node: Operators in Conditionals, Next: if-else, Prev: Conditionals and Loops, Up: Conditionals and Loops
Operators in Conditionals
-------------------------
In `if' and `while' requests, there are several more operators
available:
`e'
`o'
True if the current page is even or odd numbered (respectively).
`n'
True if the document is being processed in nroff mode (i.e., the
`.nroff' command has been issued).
`t'
True if the document is being processed in troff mode (i.e., the
`.troff' command has been issued).
`v'
Always false.
`'XXX'YYY''
True if the string XXX is equal to the string YYY. Other
characters can be used in place of the single quotes; the same set
of delimiters as for the `\D' escape is used (*note Escapes::).
`gtroff' formats the strings before being compared:
.ie "|"\fR|\fP" \
true
.el \
false
=> true
The resulting motions, character sizes, and fonts have to
match,(1) (*note Operators in Conditionals-Footnote-1::) and not
the individual motion, size, and font requests. In the previous
example, `|' and `\fR|\fP' both result in a roman `|' character
with the same point size and at the same location on the page, so
the strings are equal. If `.ft I' had been added before the
`.ie', the result would be "false" because (the first) `|'
produces an italic `|' rather than a roman one.
`r XXX'
True if there is a number register named XXX.
`d XXX'
True if there is a string, macro, diversion, or request named XXX.
`c CH'
True if there is a character CH available; CH is either an ASCII
character or a special character (`\(CH' or `\[CH]'); the
condition is also true if CH has been defined by the `char'
request.
Note that these operators can't be combined with other operators like
`:' or `&'; only a leading `!' (without whitespace between the
exclamation mark and the operator) can be used to negate the result.
.nr xxx 1
.ie !r xxx \
true
.el \
false
=> false
A whitespace after `!' always evaluates to zero (this bizarre
behaviour is due to compatibility with UNIX `troff').
.nr xxx 1
.ie ! r xxx \
true
.el \
false
=> r xxx true
It is possible to omit the whitespace before the argument to the
`r', `d', and `c' operators.
*Note Expressions::.
File: groff, Node: Operators in Conditionals-Footnotes, Up: Operators in Conditionals
(1) The created output nodes must be identical. *Note Gtroff
Internals::.
File: groff, Node: if-else, Next: while, Prev: Operators in Conditionals, Up: Conditionals and Loops
if-else
-------
`gtroff' has if-then-else constructs like other languages, although
the formatting can be painful.
- Request: .if expr anything
Evaluate the expression EXPR, and executes ANYTHING (the remainder
of the line) if EXPR evaluates to non-zero (true). ANYTHING is
interpreted as though it was on a line by itself (except that
leading spaces are swallowed). *Note Expressions::, for more info.
.nr xxx 1
.nr yyy 2
.if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
=> true
- Request: .ie expr anything
- Request: .el anything
Use the `ie' and `el' requests to write an if-then-else. The
first request is the `if' part and the latter is the `else' part.
.ie n .ls 2 \" double spacing in nroff
.el .ls 1 \" single spacing in troff
In many cases, an if (or if-else) construct needs to execute more
than one request. This can be done using the `\{' and `\}' escapes.
The following example shows the possible ways to use these escapes
(note the position of the opening and closing braces).
.ie t \{\
. ds lq ``
. ds rq ''
.\}
.el \
.\{\
. ds lq "
. ds rq "\}
*Note Expressions::.
File: groff, Node: while, Prev: if-else, Up: Conditionals and Loops
while
-----
`gtroff' provides a looping construct using the `while' request,
which is used much like the `if' (and related) requests.
- Request: .while expr anything
Evaluate the expression EXPR, and repeatedly execute ANYTHING (the
remainder of the line) until EXPR evaluates to 0.
.nr a 0 1
.while (\na < 9) \{\
\n+a,
.\}
\n+a
=> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Some remarks.
* The body of a `while' request is treated like the body of a
`de' request: `gtroff' temporarily stores it in a macro which
is deleted after the loop has been exited. It can
considerably slow down a macro if the body of the `while'
request (within the macro) is large. Each time the macro is
executed, the `while' body is parsed and stored again as a
temporary macro.
.de xxx
. nr num 10
. while (\\n[num] > 0) \{\
. \" many lines of code
. nr num -1
. \}
..
The traditional and ofter better solution (UNIX `troff'
doesn't have the `while' request) is to use a recursive macro
instead which is parsed only once during its definition.
.de yyy
. if (\\n[num] > 0) \{\
. \" many lines of code
. nr num -1
. yyy
. \}
..
.
.de xxx
. nr num 10
. yyy
..
Note that the number of available recursion levels is set
to 1000 (this is a compile-time constant value of `gtroff').
* The closing brace of a `while' body must end a line.
.if 1 \{\
. nr a 0 1
. while (\n[a] < 10) \{\
. nop \n+[a]
.\}\}
=> unbalanced \{ \}
- Request: .break
Break out of a `while' loop. Be sure not to confuse this with the
`br' request (causing a line break).
- Request: .continue
Finishes the current iteration of a `while' loop, immediately
restarting the next iteration.
*Note Expressions::.